package cc.mrbird.febs.accounting.controller;

import cc.mrbird.febs.accounting.entity.Project;
import cc.mrbird.febs.accounting.service.IProjectService;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsConstant;
import cc.mrbird.febs.common.utils.FebsUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


/**
 * @author baoyineli
 */
@Controller("accountingView")
@RequiredArgsConstructor
public class ViewController extends BaseController {

    @Autowired
    private IProjectService projectService;

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/company")
    public String companyView() {
        return FebsUtil.view("accounting/company/company");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/project")
    public String projectView() {
        return FebsUtil.view("accounting/project/project");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/projectType")
    public String projectTypeView() {
        return FebsUtil.view("accounting/project/projectType");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/project/mainSubject")
    public String mainSubject() {
        return FebsUtil.view("accounting/project/mainSubject");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/detailSubject")
    public String detailSubject() {
        return FebsUtil.view("accounting/detailSubject/detailSubject");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/detailCost")
    public String detailCost () { return FebsUtil.view("accounting/detailCost/detailCost"); }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/mainCost")
    public String mainCost () { return FebsUtil.view("accounting/mainCost/mainCost"); }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/project/comment/{projectId}")
    public String projectComment (@PathVariable("projectId") Long projectId, Model model) {
        Project projectById = projectService.getProjectById(projectId);
        model.addAttribute("project", projectById);
        return FebsUtil.view("accounting/project/comment");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/project/comment2/{projectId}")
    public String projectComment2 (@PathVariable("projectId") Long projectId, Model model) {
        Project projectById = projectService.getProjectById(projectId);
        model.addAttribute("project", projectById);
        return FebsUtil.view("accounting/project/comment2");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/importAndExport/importExcel")
    public String importExcel() {
        return FebsUtil.view("accounting/importAndExport/importExcel");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "accounting/importAndExport/exportExcel")
    public String exportExcel() {
        return FebsUtil.view("accounting/importAndExport/exportExcel");
    }

}
